package com.sz.common.core.service.role;

import org.springframework.util.StringUtils;

import java.io.Serializable;

/**
 * Function: RoleMembership <br>
 * Author: Charles <br>
 * Date: 2017-01-19 13:41:00
 */
public class RoleMembership {
    private Serializable id;
    private MembershipType membershipType;

    /**
     * @param id
     * @param membershipType
     */
    public RoleMembership(Serializable id, MembershipType membershipType) {
        this.setId(id);
        this.membershipType = membershipType;
    }

    public Serializable getId() {
        return id;
    }

    public void setId(Serializable id) {
        if (id == null || !StringUtils.hasLength(id.toString())) {
            throw new IllegalArgumentException("id cannot be empty");
        }
        this.id = id;
    }

    public MembershipType getMembershipType() {
        return membershipType;
    }

    public void setMemebershipType(MembershipType membershipType) {
        this.membershipType = membershipType;
    }

    public Integer getIdAsInteger() {
        return Integer.parseInt(id.toString());
    }
}
